home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 4 / ETO Development Tools 4.iso / Tools - Objects / MacsBug / MacsBug 6.2.1 / dcmds / C Samples / Where.c < prev   
Text File  |  1991-05-01  |  1KB  |  64 lines

  1. /* Where.c
  2.  
  3.    The following MPW commands will build the dcmd and copy it to the
  4.    "Debugger Prefs" file in the System folder. The dcmd's name in
  5.    MacsBug will be the name of the file built by the Linker.
  6.  
  7.         C Where.p
  8.         Link {dcmdLib}dcmdGlue.a.o Where.c.o {dcmdLib}DRuntime.o -o Where
  9.         BuildDcmd Where 102
  10.         Echo 'include "Where";'    |    Rez -a -o "{systemFolder}Debugger Prefs"
  11.  */
  12.  
  13. #include <Types.h>
  14. #include "dcmd.h"
  15.  
  16.  
  17. pascal void CommandEntry (dcmdBlock* paramPtr)
  18. {
  19.     short    ch;
  20.     long    address;
  21.     Boolean    ok;
  22.     Str255    name;
  23.  
  24.     switch (paramPtr->request)
  25.         {
  26.         case dcmdInit:
  27.             break;
  28.  
  29.         case dcmdHelp:
  30.             dcmdDrawLine ("\pWHERE [addr | trap]");
  31.             dcmdDrawLine ("\p   Display information about the address or trap");
  32.             dcmdDrawLine ("\p   If no parameter then use PC as the address");
  33.             break;
  34.  
  35.         case dcmdDoIt:
  36.             if (dcmdPeekAtNextChar () == '\n')
  37.                 address = paramPtr->registerFile[PCRegister];
  38.             else
  39.                 {
  40.                 ch = dcmdGetNextExpression (&address, &ok);
  41.                 if (!ok)
  42.                     {
  43.                     dcmdDrawLine ("\pSyntax error");
  44.                     return;
  45.                     }
  46.                 }
  47.  
  48.             if (address >= 0x0000A000 && address <= 0x0000ABFF)
  49.                 {
  50.                 dcmdGetTrapName (address, name);
  51.                 dcmdDrawLine (name);
  52.                 }
  53.             else
  54.                 {
  55.                 dcmdGetNameAndOffset (address, name);
  56.                 if (name[0] > 0)
  57.                     dcmdDrawLine (name);
  58.                 else
  59.                     dcmdDrawLine ("\pNo procedure name found");
  60.                 }
  61.             break;
  62.         }
  63. } // CommandEntry
  64.